<?php

namespace app\admin\model;

use think\Model;


class Dxdaylog extends Model
{

    

    

    // 表名
    protected $name = 'dxdaylog';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'ctype_text',
        'ptype_text'
    ];
    

    
    public function getCtypeList()
    {
        return ['1' => __('Ctype 1'), '2' => __('Ctype 2')];
    }

    public function getPtypeList()
    {
        return ['1' => __('Ptype 1'), '2' => __('Ptype 2'), '3' => __('Ptype 3'), '4' => __('Ptype 4'), '5' => __('Ptype 5'), '0' => __('Ptype 0')];
    }


    public function getCtypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['ctype']) ? $data['ctype'] : '');
        $list = $this->getCtypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getPtypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['ptype']) ? $data['ptype'] : '');
        $list = $this->getPtypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function admin()
    {
        return $this->belongsTo('Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
